if (typeof (mediator) == 'undefined')
	mediator = {};

if (typeof (mediator.wantStudy) == 'undefined')
	mediator.wantStudy = {};

var pageSize = 10;


mediator.wantStudy.createViewMediator = function(options) {
	var settings = $.extend({
		teachingsListApp : {}
	}, options || {});
	var viewModel = mediator.teachingList.createViewMediator();
	mediator.wantStudy.renderView();
	var viewNode = $('#teachesView')[0];
	bindPage(viewModel);
	applyBindings(viewModel, viewNode);
	return viewModel;
};

// 初始化页面
mediator.wantStudy.renderView = function() {
	$('#teachCourseName').attr('data-bind',
			'text : course().name, click : wantSdutyHref');
	$('#pp').attr('data-bind', 'visible : teachings().length > 0');
}

function bindPage(viewModel) {
	$('#pp').pagination({
		total : viewModel.total(),
		pageSize : viewModel.pageSize,
		showPageList : false,
		onSelectPage :  function(pageNumber, pageSize) {
			viewModel.removeAllTeachings();
			var data = getOtherPeoplesTeachings('lasts', pageNumber, pageSize);
			pushTeachingsArray(data.teaches, viewModel.teachings);
		}
	});
}
